/*
 * Copyright (c) 2024 dragonSaberCaptain.All rights reserved.
 * 当前项目名:wisdom-parent
 * 当前模块名:openai-core
 * 当前文件的权限定名:com.wisdom.openai.entity.AuthenticationInterceptor
 * 当前文件的名称:AuthenticationInterceptor.java
 * 当前文件的类名:AuthenticationInterceptor
 * 上一次文件修改的日期时间:2023/7/26 下午2:16
 *
 */

package com.wisdom.openai.entity;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;

public class AuthenticationInterceptor implements Interceptor {
    private final String token;

    public AuthenticationInterceptor(String token) {
        this.token = token;
    }

    @NotNull
    public Response intercept(Interceptor.Chain chain) throws IOException {
        Request request = chain.request().newBuilder().header("Authorization", "Bearer " + this.token).build();
        return chain.proceed(request);
    }
}
